#ifndef __OC_MapCacher_H__
#define __OC_MapCacher_H__

#include "ServerDef.h"
#include "OCMain/StringUtil.h"

namespace OCPP
{
	class _ServerExport MapCacher
	{
	public:
		MapCacher(String url, String cachePath, String ext, StringVector subdomains = {});
		~MapCacher();

		String getCacheSync(String layer, String path);
		String getCacheSync(String layer, int z, int y, int x);
		String getCache(String layer, int z, int y, int x);
		String getCache(String layer, String path);
		bool exist(String layer, int z, int y, int x);
		static void shutdown();
	protected:
		static std::unique_ptr<MapCacherWorkQueue> _mapCacherWorkQueue;
		void init();
		String GenUrl(String layer, int z, int y, int x);
		bool _initilized = false;
		String _url;
		String _path;
		String _ext;
		StringVector _subdomains;
		StringMap _missingMap;
		std::map<String, bool> _forbiddens;
		CORE_AUTO_MUTEX;
	};
}

#endif